<html xmlns="http://www.w3c.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pe="http://primefaces.org/ui/extensions">
<h:head>
	<script type="text/javascript">
		//<![CDATA[
		//debe usarse los \\:  en lugar de : en los selectores de JQuery
		$(document).ready(function() {

		});
		//]]>
	</script>
</h:head>

<h:body>
	<h:form id="form_all_assistances_data">
		<h2>
			<h:outputLabel value="Datos de asistencia técnica" />
		</h2>
		<div class="clearfix common-panel">
			<div class="ui-form-row-2col clearfix">
				<div class="ui-form-col">
					<div class="clearfix text-align-left">
						<h:outputLabel value="PRODUCTOR:" />
					</div>
					<div class="clearfix text-align-left">
						<h:outputLabel value="#{aSession.selectedRuatRegister.fullName}" />
					</div>
				</div>
				<div class="ui-form-col">
					<div class="clearfix text-align-left">
						<h:outputLabel value="Cedula:" />
					</div>
					<div class="clearfix text-align-left">
						<h:outputLabel value="#{aSession.selectedRuatRegister.idNumber}" />
					</div>
				</div>
			</div>

			<div class="ui-form-row-2col clearfix">
				<div class="ui-form-col">
					<div class="clearfix text-align-left">
						<h:outputLabel value="FINCA" />
					</div>
					<div class="clearfix text-align-left">
						<h:outputLabel value="#{aSession.selectedRuatRegister.farmName}" />
					</div>
				</div>
				<div class="ui-form-col">
					<div class="clearfix text-align-left">
						<h:outputLabel value="CADENA PRODUCTIVA" />
					</div>
					<div class="clearfix text-align-left">
						<p:selectOneMenu
							value="#{aSession.selectedDealAssistenceRegister.dealTechnicalAssistance.productionLine}"
							required="true">
							<f:selectItem itemLabel="#{i18n['cmpnt.select_one']}"
								itemValue="1" noSelectionOption="true" />
							<f:selectItems value="#{aSession.optionsProducts}" />
						</p:selectOneMenu>
					</div>
				</div>
			</div>
			<p:panel id="locationsFarm" styleClass="clearfix">
				<!-- 			<div class="ui-form-row-3col clearfix"> -->
				<div class="ui-form-row-2col clearfix">
					<div class="ui-form-col">
						<div class="clearfix text-align-left">
							<h:outputLabel
								value="#{i18n['lbl.owner.farm_general_data.farm_department']}" />
						</div>
						<div class="clearfix text-align-left">
							<p:selectOneMenu
								value="#{aSession.selectedRuatRegister.farmDepartament}"
								disabled="true">
								<f:selectItem itemLabel="#{i18n['cmpnt.select_one']}"
									itemValue="" noSelectionOption="true" />
								<f:selectItems value="#{farmLocationController.departments}" />
								<p:ajax event="change" update="locationsFarm"
									listener="#{farmLocationController.toogleDeparment}" />
							</p:selectOneMenu>
						</div>
					</div>
					<div class="ui-form-col"></div>
				</div>
				<div class="ui-form-row-2col clearfix">
					<div class="ui-form-col">
						<div class="clearfix text-align-left">
							<h:outputLabel
								value="#{i18n['lbl.owner.farm_general_data.farm_municipality']}" />
						</div>
						<div class="clearfix text-align-left">
							<p:selectOneMenu
								value="#{aSession.selectedRuatRegister.farmMunicipality}"
								disabled="true">
								<f:selectItem itemLabel="#{i18n['cmpnt.select_one']}"
									itemValue="" noSelectionOption="true" />
								<f:selectItems value="#{farmLocationController.municipalities}" />
								<p:ajax event="change" update="locationsFarm"
									listener="#{farmLocationController.toogleMunicipality}" />
							</p:selectOneMenu>
						</div>
					</div>
					<div class="ui-form-col">
						<div class="clearfix text-align-left">
							<h:outputLabel
								value="#{i18n['lbl.owner.farm_general_data.farm_village']}" />
						</div>
						<div class="clearfix text-align-left">
							<p:selectOneMenu
								value="#{aSession.selectedRuatRegister.farmVillage}"
								disabled="true">
								<f:selectItem itemLabel="#{i18n['cmpnt.select_one']}"
									itemValue="" noSelectionOption="true" />
								<f:selectItems value="#{farmLocationController.villages}" />
								<p:ajax event="change" update="locationsFarm"
									listener="#{farmLocationController.toogleVillage}" />
							</p:selectOneMenu>
						</div>
					</div>
				</div>

				<div class="ui-form-row-3col clearfix">
					<div class="ui-form-col">
						<div class="clearfix text-align-left">
							<h:outputLabel value="Latitud Norte" />
						</div>
						<div class="clearfix text-align-left">
							<p:inputText
								value="#{aSession.selectedDealAssistenceRegister.dealTechnicalAssistance.northLatitude}"
								required="true" />
						</div>
					</div>
					<div class="ui-form-col">
						<div class="clearfix text-align-left">
							<h:outputLabel value="Longitud Oeste" />
						</div>
						<div class="clearfix text-align-left">
							<p:inputText
								value="#{aSession.selectedDealAssistenceRegister.dealTechnicalAssistance.westLongitude}"
								required="true" />
						</div>
					</div>
					<div class="ui-form-col">
						<div class="clearfix text-align-left">
							<h:outputLabel value="Altitud" />
						</div>
						<div class="clearfix text-align-left">
							<p:inputText
								value="#{aSession.selectedDealAssistenceRegister.dealTechnicalAssistance.altitude}"
								required="true" />
						</div>
					</div>
				</div>
			</p:panel>
			
			<div class="buttons-container clearfix text-align-right">
				<p:commandButton value="Guardar" styleClass="ui-flowbutton"
					validateClient="true" update="form_all_assistances_data"
					actionListener="#{assistanceController.saveDealAssistence}" />
			</div>

		</div>

		<p:panel id="visitsPanel"
			visible="#{aSession.selectedDealAssistenceRegister.dealTechnicalAssistance.id!=null}">
			<div class="clearfix common-panel">
				<div class="buttons-container clearfix text-align-left">
					<p:commandButton value="Nueva Visita" styleClass="ui-flowbutton"
						validateClient="true" update="form_all_assistances_data"
						actionListener="#{assistanceController.newDealAssistenceVisit}" />
				</div>
				<p:accordionPanel id="visit_acordion"
					value="#{aSession.selectedDealAssistenceRegister.dealTechnicalAssistanceVisits}"
					var="registerItem" activeIndex="-1" multiple="true">
					<p:tab title="Visita #{registerItem.position}">
						<div class="ui-form-row-2col clearfix">
							<div class="ui-form-col">
								<div class="clearfix text-align-left">
									<h:outputLabel value="FECHA" />
								</div>
								<div class="clearfix text-align-left">
									<p:calendar id="bornDate" value="#{registerItem.visitDate}"
										required="true" requiredMessage="#{i18n['cmpnt.required']}"
										navigator="true" pattern="MM/dd/yyyy"
										maxdate="calwidget.today()" mindate="01/01/1900"
										yearRange="c-100:c+100" />
									<p:message for="bornDate" />
								</div>
							</div>
							<div class="ui-form-col">
								<div class="clearfix text-align-left">
									<h:outputLabel value="No. Formulario" />
								</div>
								<div class="clearfix text-align-left">
									<p:inputText id="formNumber" value="#{registerItem.formNumber}"
										required="true" requiredMessage="#{i18n['cmpnt.required']}"
										maxlength="12" />
									<p:message for="formNumber" />
									<pe:keyFilter for="formNumber" mask="int" />
								</div>
							</div>
						</div>
						<br />

						<div class="ui-form-row-col clearfix">
							<div class="ui-form-col">
								<div class="clearfix text-align-left">
									<h:outputLabel value="OBJETIVO DE LA VISITA Y PUNTOS A DESARROLLAR" />
								</div>
								<div class="clearfix text-align-left">
								<p:inputTextarea maxlength="2600" cols="130"
									value="#{registerItem.objective}" />
								</div>
							</div>					
						
						
	
							
							<div class="ui-form-col">
								<div class="clearfix text-align-left">
									<h:outputLabel value="DIAGNÓSTICO O SITUACIÓN ENCONTRADA" />
								</div>
								<div class="clearfix text-align-left">
								<p:inputTextarea maxlength="2600" cols="130"
									value="#{registerItem.diagnosis}" />
								</div>
							</div>					
						
						
						
							<div class="ui-form-col">
								<div class="clearfix text-align-left">
									<h:outputLabel value="NIVEL DE CUMPLIMIENTO (Con respecto a la anterior visita)" />
								</div>
								<div class="clearfix text-align-left">
								<p:inputTextarea maxlength="2600" cols="130"
									value="#{registerItem.fulfillmentComent}" />
								<div class="clearfix text-align-left">

									<h:outputLabel value="Precisar nivel de cumplimiento (%)" />
									<p:inputText id="idNumber"
										value="#{registerItem.fulfillmentLevel}" required="true"
										requiredMessage="#{i18n['cmpnt.required']}" maxlength="3" />
									<p:message for="idNumber" />
									<pe:keyFilter for="idNumber" mask="int" />
								</div>
								</div>
							</div>					
						
						
						
							<div class="ui-form-col">
								<div class="clearfix text-align-left">
									<h:outputLabel value="RECOMENDACIONES Y COMPROMISOS DE LAS PARTES" />
								</div>
								<div class="clearfix text-align-left">
								<p:inputTextarea maxlength="2600" cols="130"
									value="#{registerItem.commitmentsRecommendations}" />
								</div>
							</div>					
						</div>											


						<br />
						<div class="clearfix text-align-left">
							<h:outputLabel value="FACILITADOR" />
						</div>
						<div class="clearfix text-align-left">
							<p:inputText id="facilitardorUsername"
								value="#{registerItem.facilitatorUsername}" disabled="true"
								required="true" requiredMessage="#{i18n['cmpnt.required']}"
								maxlength="24" />
						</div>
						
						<p:panel  >
						<div class="buttons-container clearfix text-align-right">
							<p:growl id="mensaj" showDetail="true" />
							<p:commandButton value="Guardar" styleClass="ui-flowbutton"
								validateClient="true" update="visit_acordion mensaj"
								actionListener="#{assistanceController.saveDealAssistenceVisit}">
								<f:attribute name="visitDTO" value="#{registerItem}" />
							</p:commandButton>
							
						</div>
						</p:panel>

						<p:panel id="fileUpDw" visible="#{registerItem.id!=null}">

							<br />
							<br />
							<div class="clearfix common-panel">
								<div class="clearfix text-align-left">
									<H4>
										<h:outputLabel value="Archivo PDF de evidencia" />
									</H4>
								</div>
								<div class="clearfix text-align-left">
									<p:panel id="fileYes"
										visible="#{registerItem.evidenceFileName!=null}">
										<h:outputLabel value="Archivo de evidencia ya cargado" />
										<br />
										<br />
										<p:commandLink id="downloadLink1"
											value="#{registerItem.evidenceFileName}" ajax="false"
											actionListener="#{assistanceController.initFile}"
											immediate="true" style="margin-right:20px;">
											<h:outputText value="#{registerItem.evidenceFileName}" />
											<f:attribute name="filename"
												value="#{registerItem.evidenceFileName}" />
											<f:attribute name="visitDTO" value="#{registerItem}" />
											<p:fileDownload value="#{assistanceController.file}" />
										</p:commandLink>
									</p:panel>
									<p:panel id="fileNo"
										visible="#{registerItem.evidenceFileName==null}">
										<h:outputLabel value="Archivo de evidencia no cargado" />
									</p:panel>
								</div>

								<br />
								<div class="clearfix text-align-left">
									<p:fileUpload
										fileUploadListener="#{assistanceController.handleFileUpload}"
										mode="advanced" update="fileUpDw" auto="true"
										sizeLimit="2000000" allowTypes="/(\.|\/)(pdf)$/"
										label="Cargar o Remplazar Archivo de evidencia">
										<f:attribute name="filename"
											value="#{registerItem.evidenceFileName}" />
										<f:attribute name="visitDTO" value="#{registerItem}" />
									</p:fileUpload>
									<p:growl id="messages" showDetail="true" />
								</div>
							</div>
						</p:panel>
					</p:tab>
				</p:accordionPanel>
			</div>
		</p:panel>
	</h:form>

</h:body>

</html>